<?php
namespace App\Service\AliyunService;

use App\Service\BaseService;
use App\Service\AppService\SystemCacheConfigService;
use Service\VendorClient\Aliyun\AliyunLatlngtoAddressQueryClient;
use Service\VendorClient\Qmap\QmapApiClient;

/**
 * 查询经纬°地址服务中心
 * @author chenshubo
 */
class QueryLatLngtoAddressService extends BaseService
{
    /**
     * 物流轨迹批量查询服务
     * @param array $param
     * @return mixed
     */
    public function QueryAddressByLatLngto(string $lat,string $lng)
    {
        $config = SystemCacheConfigService::instance()->getCacheInfoBySystemCode('aliyun_latlngto_query');
        if( empty($config) ) 
        {
            $config = [
                'key'       => 'NKFBZ-HCA6J-NYMFK-KFM4Z-XMI5F-C6FC3',
                'secret'    => 'nkCvTxQNAEa9RrRVM4vZCBmIxjFs5xt',
                'baseurl'   => 'https://apis.map.qq.com/ws/geocoder/v1'
            ];
            $result = (new QmapApiClient($config))->queryAddressByLatLng($lat,$lng);
        } else {
            $result = (new AliyunLatlngtoAddressQueryClient($config))->queryAddressByLatLng($lat,$lng);
        }
        return $result;
    }
}